#  Copyright (c) 1997-2010
#  Ewgenij Gawrilow, Michael Joswig (Technische Universitaet Darmstadt, Germany)
#  http://www.polymake.de
#
#  This program is free software; you can redistribute it and/or modify it
#  under the terms of the GNU General Public License as published by the
#  Free Software Foundation; either version 2, or (at your option) any
#  later version: http://www.gnu.org/licenses/gpl.txt.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#-------------------------------------------------------------------------------
#  $Project: polymake $$Id: configure_java 9931 2010-11-19 19:58:46Z gawrilow $

# an interactive script, forcing the configuration dialogs for java packages

use application "common";

reconfigure("javaview.rules");

my @vars;
if ($java) {
   @vars=( JAVACMD => $java,
           JNI_HEADERS => Java::Configure::find_jni_headers($java),
           JavaViewPath => $JavaView::Viewer::install_top || ".none.",
         );

   if ($^O eq "darwin") {
       my $java_cmd=Java::Configure::find_java_cmd($java) or return;
      (my $archflags=`lipo -info $java_cmd`) =~ s/.* are: (.*)$/$1/m;
      $archflags =~ s/(\S+)/-arch $1/g;;
      push @vars, (NativeArchFlags => $archflags);
   }
} else {
   @vars=( JAVACMD => undef,
           JNI_HEADERS => undef,
	   JavaViewPath => undef,
	   JavaBuild => "n",
	 );
}

$application->cpp->store_in_conf_makefile($InstallTop, @vars);

# Local Variables:
# mode: perl
# cperl-indent-level: 3
# End:
